/**
 * Copyright (C), 2019-2020, 宇信融汇
 * FileName: TestPet
 * Author:   xbliu
 * Date:     2020/6/29 8:56
 * Description: 测试父类强转子类
 * History:
 * <author>          <time>          <version>          <desc>
 * xbliu           修改时间           版本号              描述
 */
package c_006;

/**
 * @Classname TestPet
 * @Description TODO
 * @Date 2020/6/29 8:56
 * @Created by xbliu
 */
public class TestPet {
    public static void main(String[] args) {
        Pet p = new Dog();
        p.feed();

        if (p instanceof Cat) {
            ((Cat) p).sound();
        } else if (p instanceof Dog) {
            ((Dog) p).sound();
        } else {
            System.out.println("数据类型转换错误");
        }

    }

}
